<template>
  <header class="header">
    <h1>todos</h1>
    <input
      class="new-todo"
      v-model="name"
      @keyup.enter="add"
      placeholder="What needs to be done?"
      v-header-focus
    />
  </header>
</template>

<script>
// import { mapGetters } from 'vuex'
export default {
  data() {
    return {
      name: '',
    }
  },
  methods: {
    add() {
      if (!this.name) {
        return alert('请输入任务名')
      }
      this.$store.commit('todos/add', this.name)
      this.name = ''
    },
  },
}
</script>

<style></style>
